package com.jiyun.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jiyun.common.result.Result;
import com.jiyun.model.pojo.SysRegion;
import com.jiyun.model.query.SysRegionQuery;
import com.jiyun.service.SysRegionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/region")
public class SysRegionController {

    @Autowired
    private SysRegionService sysRegionService;

    @GetMapping("/{page}/{limit}")
    @ApiOperation("获取所有")
    public Result getPageList(@PathVariable Integer page, @PathVariable Integer limit, SysRegionQuery query) {
        //封装分页参数
        query.setCurrentPage(page);
        query.setPageSize(limit);
        //查询分页数据
        IPage<SysRegion> pageList = sysRegionService.getPageList(query);
        return Result.ok(pageList);
    }

    @GetMapping("/getList")
    public Result getList(){
        return Result.ok(sysRegionService.list());
    }
}
